// Package public 基础库
package public

import (
	"fmt"

	"github.com/go-gomail/gomail"
)

//SendMailBy163 send to  163
func SendMailBy163(message string) {
	m := gomail.NewMessage()
	m.SetAddressHeader("From", "wang_cyi@163.com", "Future") // 邮件发件人
	m.SetHeader("To",                                        // 邮件收件人
		m.FormatAddress("wang_cyi@163.com", "Now"),
	)
	m.SetHeader("Subject", "Daily Checking")
	m.SetBody("text/plain", message)
	//demo https://github.com/go-gomail/gomail/blob/master/example_test.go
	//m.Attach("/home/Alex/lolcat.jpg")

	d := gomail.NewPlainDialer("smtp.163.com", 25, "wang_cyi@163.com", "qwer@1234") // 发送邮件服务器、端口、发件人账号、发件人密码
	if err := d.DialAndSend(m); err != nil {
		//panic(err)
		fmt.Println(err)
	}
}
